package cn.westv.scps.domain;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.GenericGenerator;

/**
 * Created by Administrator on 2017/08/09.
 */
@Entity(name = "bike_owner")
// @Table(name = "bike_owner", schema = "scps", catalog = "")
public class BikeOwnerEntity implements Serializable{
	private String bikeOwnerId;
	private String account;
	private String mobile;
	private AreaSeverEntity areaSever;

	@Id
	@Column(name = "bike_owner_id", nullable = false, length = 32)
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	public String getBikeOwnerId() {
		return bikeOwnerId;
	}

	public void setBikeOwnerId(String bikeOwnerId) {
		this.bikeOwnerId = bikeOwnerId;
	}

	@Basic
	@Column(name = "account", nullable = false, length = 32)
	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	@Basic
	@Column(name = "mobile", nullable = false, length = 16)
	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	@ManyToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "server_id")
	public AreaSeverEntity getAreaSever() {
		return areaSever;
	}

	public void setAreaSever(AreaSeverEntity areaSever) {
		this.areaSever = areaSever;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		BikeOwnerEntity that = (BikeOwnerEntity) o;

		if (bikeOwnerId != null ? !bikeOwnerId.equals(that.bikeOwnerId) : that.bikeOwnerId != null)
			return false;
		if (account != null ? !account.equals(that.account) : that.account != null)
			return false;
		if (mobile != null ? !mobile.equals(that.mobile) : that.mobile != null)
			return false;

		return true;
	}

	@Override
	public int hashCode() {
		int result = bikeOwnerId != null ? bikeOwnerId.hashCode() : 0;
		result = 31 * result + (account != null ? account.hashCode() : 0);
		result = 31 * result + (mobile != null ? mobile.hashCode() : 0);
		return result;
	}

	@Override
	public String toString() {
		return "BikeOwnerEntity [bikeOwnerId=" + bikeOwnerId + ", account=" + account + ", mobile=" + mobile
				+ ", areaSever=" + areaSever + "]";
	}
	
}
